package org.saiht.guestbook;

import java.io.IOException;

import javax.jdo.PersistenceManager;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserServiceFactory;

@SuppressWarnings("serial")
public class GuestBookServlet extends HttpServlet {
	
	public void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		
		String poster = req.getParameter("poster");
		String content = req.getParameter("content");
		
		GuestBookEntry entry = new GuestBookEntry(poster, content);
		
		/*
		 * Save ticket to the database
		 */
		PersistenceManager pm = PMF.get().getPersistenceManager();
		pm.makePersistent(entry);
		pm.close();
				
		resp.sendRedirect("guestbook.jsp");
	}
}
